

window.rnd = 
    choose : (arr) ->
        i = Math.random() * arr.length
        i |= 0
        return arr[i]

    rndCell : (bounds) ->
        dx = bounds[2] - bounds[0]
        dy = bounds[3] - bounds[1]

        x = dx * Math.random()
        x |= 0
        x += bounds[0]
        y = dy * Math.random()
        y |= 0
        y += bounds[1]

        return [x, y]

    chooseRndCellInAreas : (arr) ->
        return window.rnd.rndCell window.rnd.choose arr